package com.iotechn.unimall.data.dto.purchase;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
import com.iotechn.unimall.data.dto.SuperDTO;
import lombok.Data;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.Date;

/**
 * 采购单商品
 */
@ExcelTarget("purchaseOrderGoodsDTO")
@Data
public class PurchaseOrderGoodsDTO extends SuperDTO implements Serializable {

    //入库单号
    @Excel(name = "单号", width = 20d)
    private String pOrderNo;
    private Long pOrderId;
    private Long warehouseId;
    private Long goodsId;
    private String goodsName;
    private String goodsNo;

    private String goodsSpec;
    @Excel(name = "名称")
    private String spuName;
    @Excel(name = "规格")
    private String skuName;
    private String goodsUnit;
    @Excel(name = "条码", width = 20d)
    private String barCode;

    private String img;
    @Excel(name = "单位")
    private String unit;
    @Excel(name = "计划数量")
    private Float pGoodsBuyNum;
    @Excel(name = "实际数量")
    private Float pGoodsActualNum;
    @Excel(name = "单价")
    private Float pGoodsPrice;
    @Excel(name = "总价")
    private Float pGoodsAmount;
    private Float goodsTotalPrice;
    private String goodsImg;
    private String goodsBarCode;

    private Long skuId;

    private Long spuId;


    @Excel(name = "状态", replace = {"待采购_0", "已采购_1", "驳回_-1", " _ "})
    private Integer orderState;
    @Excel(name = "仓库")
    private String warehouseName;
    @Excel(name = "供应商")
    private String supplierName;

    @Excel(name = "制单日期", databaseFormat = "yyyyMMddHHmmss", format = "yyyy-MM-dd HH:mm:ss")
    private Date gmtCreate;


    public Float getGoodsTotalPrice() {
        if (this.pGoodsBuyNum == null || this.pGoodsPrice == null) {
            return 0F;
        }
        DecimalFormat decimalFormat = new DecimalFormat(".00");
        String total = decimalFormat.format((this.pGoodsBuyNum * this.pGoodsPrice));
        return Float.valueOf(total);
    }
}
